|
|
|
|
|
|
|
Note If you don't have at least one child form loaded when you use the ActiveForm property, an error will occur. |
|
|
|
|
|
|
|
|
|
When exiting the MDI application, you need a way to determine whether any of the data in the child form has been modified and should be saved. By using a Boolean variable, you can set its value to True in the Input control's Change event routine and reset it to False when users save the data. Then, when unloading the application, you can check this variable to see whether executing the save routine is needed. |
|
|
|
|
|
|
|
|
When the MDI form is unloaded, the QueryUnload event is invoked first for the MDI form and then for every open child form. If none of the processing in this event cancels the Unload event, each child form is unloaded, and then the MDI form is finally unloaded. Because the QueryUnload event executes before the form is actually unloaded, you can give users a chance to save their data before unloading it. It's in this form that you would check to see if the Boolean variable was set to True. |
|
|
|
|
|
|
|
|
Run the simple application to see how the child form is handled at startup time and when you choose File, New on the menu (see Figure 3.11). |
|
|
|
|
|
|
|
|
Figure 3.11.
Creating several child forms within the MDI application. |
|
|
|
|
|